import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
// 获取本地购物车数据列表
let cartList = localStorage.getItem("cartList");
let userId = localStorage.getItem("userid");
let geohash = localStorage.getItem('geohash')
export default new Vuex.Store({
  state: {
    // 存放当前店铺详情数据
    shopInfo:null,
    cartList:cartList?JSON.parse(cartList):null,
    userId:userId?userId:null,
    geohash:geohash,
    city:null
  },
  getters: {
  },
  mutations: {
    getShopInfo(state,info){
      state.shopInfo = info
    },
    addCartList(state,cartList){
      console.log(1221212121)
      state.cartList = cartList;
      console.log(state.cartList)
    },
    saveUserid(state,id){
      state.userId = id;
    },
    savegeohash(state,geohash){
      state.geohash = geohash;
    },
    changeCity(state,city){
      state.city = city
    }
  },
  actions: {
  },
  modules: {
  }
})